<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace app\cpmjagent\controller\user;

/**
 * Description of UserController
 *
 * @author SoChishun
 */
class UserController extends \app\cpmjagent\controller\AppbaseController {

    public function profile() {
        $data = \app\cpmjagent\model\user\AgentModel::get($this->global_data['userid']);
        return view('', ['data' => $data]);
    }

    public function doSaveProfile($realname='',$mobile = '',$qq='',$wechat_id='') {
        $mAgent = new \app\cpmjagent\model\user\AgentModel();
        $data['realname'] = $realname;
        $data['mobile'] = $mobile;
        $data['wechat_id'] = $wechat_id;
        $data['qq'] = $qq;
        $mAgent->save($data, ['id' => $this->global_data['userid']]);
        $this->success('保存成功!', '!window.parent.location.reload();', '', 1);
    }

    public function password_edit() {
        return view();
    }

    public function doSavePassword($password = '', $repassword = '') {
        \app\cpmjagent\model\user\AgentModel::update(['password' => $password], ['id' => $this->global_data['userid']]);
        $this->success('保存成功!', url('password_edit'));
    }

}
